//
//  ZDCtlView.m
//  MJAVFoundationDemo
//
//  Created by apple on 16/9/21.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZDCtlView.h"

@implementation ZDCtlView
-(id)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame])
    {
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI
{
    UIButton *pauseBtn=[[UIButton alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
    [pauseBtn setBackgroundImage:[UIImage imageNamed:@"icon_play"] forState:UIControlStateNormal];
    [pauseBtn setContentMode:UIViewContentModeScaleAspectFill];
    [pauseBtn setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleHeight];
    [pauseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [pauseBtn addTarget:self action:@selector(clickOnPause) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:pauseBtn];
    
    UILabel *currentTime=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(pauseBtn.frame)+10, 5, 50, 30)];
    currentTime.text=@"0:00";
    [currentTime setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleHeight];
    currentTime.textColor=[UIColor whiteColor];
    currentTime.textAlignment=NSTextAlignmentCenter;
    currentTime.adjustsFontSizeToFitWidth=YES;
    [self addSubview:currentTime];
    
    UIButton *fullScreenBtn=[[UIButton alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.frame)-30, 10, 20, 20)];
    [fullScreenBtn setBackgroundImage:[UIImage imageNamed:@"quanping"] forState:UIControlStateNormal];
    [fullScreenBtn setContentMode:UIViewContentModeScaleAspectFill];
    [fullScreenBtn addTarget:self action:@selector(clickOnFullScreen) forControlEvents:UIControlEventTouchUpInside];
     [fullScreenBtn setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleHeight];
    [self addSubview:fullScreenBtn];
    
    UILabel *totalTime=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(fullScreenBtn.frame)-15-40, 5, 50, 30)];
    totalTime.text=@"4:00";
    totalTime.textColor=[UIColor whiteColor];
    [totalTime setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleHeight];
    totalTime.textAlignment=NSTextAlignmentCenter;
    totalTime.adjustsFontSizeToFitWidth=YES;
    [self addSubview:totalTime];
   
    UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(CGRectGetMaxX(currentTime.frame)+5, 10, CGRectGetWidth(self.frame)-190, 20)];
    slider.value=0.5;
    [slider setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin];
    [slider setThumbImage:[UIImage imageNamed:@"point_normal"] forState:UIControlStateNormal];
    slider.tintColor=[UIColor whiteColor];
    [self addSubview:slider];
    
  
}
-(void)clickOnPrevious
{
    
}
-(void)clickOnPause
{
    
}
-(void)clickOnNext
{
    
}
-(void)clickOnFullScreen
{
    [[NSNotificationCenter defaultCenter]postNotificationName:@"Full" object:nil];
}
@end
